package kuangshen.juc;

import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @program: liangt
 * @description: 测试JUC
 * @author: liangt
 * @create: 2021-03-03 15:47
 */
public class TestJUC {

    public static void main(String[] args) {
        CopyOnWriteArrayList<String> list = new CopyOnWriteArrayList<String>(); //线程安全的

        for (int i = 0; i < 10000; i++){
            new Thread(()->{
               list.add(Thread.currentThread().getName());
            });
        }

        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(list.size());


    }
}
